home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / MultiSession 1.04 Source / Core 27⁄June⁄1993 / CModalDialog.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-09  |  1.8 KB  |  63 lines  |  [TEXT/KAHL]

  1. /* CModalDialog.c */
  2.  
  3. #define COMPILING_CMODALDIALOG_C
  4. #include "CModalDialog.h"
  5. #include "EventLoop.h"
  6. #include "MenuController.h"
  7. #include "CScrap.h"
  8. #include "CApplication.h"
  9.  
  10.  
  11. /* */        CModalDialog::~CModalDialog()
  12.     {
  13.         ERROR(Initialized != True,PRERR(ForceAbort,
  14.             "CModalDialog::~CModalDialog called on uninitialized object."));
  15.         *GoAwayLocation = True; /* makes the event loop quit as soon as possible */
  16.     }
  17.  
  18.  
  19. /* after calling this from your initialization routine, call DoEventLoop */
  20. void        CModalDialog::IModalDialog(LongPoint Start, LongPoint Extent,
  21.                     MyBoolean AllowMenus)
  22.     {
  23.         ERROR(Initialized == True,PRERR(ForceAbort,
  24.             "CModalDialog::IModalDialog called on already initialized object."));
  25.         EXECUTE(Initialized = True);
  26.         IWindow(Start,Extent,ModalWindow,NoGrowable,NoZoomable);
  27.         SelectWindow(MyGrafPtr);
  28.     }
  29.  
  30.  
  31. void        CModalDialog::MakeMyGrafPtr(LongPoint Start, LongPoint Extent)
  32.     {
  33.         Rect        BoundsRect;
  34.  
  35.         ERROR(Initialized != True,PRERR(ForceAbort,
  36.             "CModalDialog::MakeMyGrafPtr called on uninitialized object."));
  37.         ERROR(MyGrafPtr!=NIL,PRERR(ForceAbort,
  38.             "CModalDialog::MakeMyGrafPtr MyGrafPtr is not NIL."));
  39.         BoundsRect = RectOf(Start.x,Start.y,Start.x+Extent.x,Start.y+Extent.y);
  40.         MyGrafPtr = NewWindow(NIL,&BoundsRect,"\p",True,dBoxProc,(void*)-1,True,(long)this);
  41.         if (MyGrafPtr == NIL)
  42.             {
  43.                 PRERR(ForceAbort,"NewWindow failed to allocate memory.");
  44.             }
  45.     }
  46.  
  47.  
  48. void        CModalDialog::DoEventLoop(void)
  49.     {
  50.         EventRecord        MyEvent;
  51.         WindowPtr            WhichWindow;
  52.         MyEventRec        SpiffEvent;
  53.         short                    MenuCommand;
  54.         MyBoolean            GoAwayNow;
  55.         long                    MenuCommandStart;
  56.  
  57.         ERROR(Initialized != True,PRERR(ForceAbort,
  58.             "CModalDialog::DoEventLoop called on uninitialized object."));
  59.         GoAwayLocation = &ModalWindowTerminationFlag;
  60.         TheEventLoop(this);
  61.         ActiveWindow = NIL; /* we end by having delete performed on us */
  62.     }
  63.